<?php
//by willson 105328468@qq.com 2014/10/11
//index page interface

class brand extends core {
	public function __construct() {
		parent::__construct();

	}

	//品牌首页
	public function index(){
		$offset = (isset($_GET['offset']) && trim($_GET['offset'])) ? intval($_GET['offset']) : 0;
		$pagesize = (isset($_GET['pagesize']) && trim($_GET['pagesize'])) ? intval($_GET['pagesize']) : 8;
		$sql ="SELECT * FROM {$this->tbp}brand WHERE status='1' ORDER BY sort ASC, id DESC LIMIT {$offset}, {$pagesize}";
		$rs = $this->db->get_results($sql);
		if ($rs) {
			foreach ($rs as $k => $c) {

			}
			$rs = add_domain_deep($rs, array("pic", "banner"));
		}
		$flashes = $this->_flashes();
		success(array("flashes"=>$flashes, "brands"=>$rs));
	}

	//幻灯广告
	private function _flashes() {
		$now = time();
		$sql = "SELECT * FROM {$this->tbp}ad WHERE position='brand' AND status='1'
			ORDER BY sort ASC, id DESC LIMIT 5";
		$ads = $this->db->get_results($sql);
		if ($ads) {
			$ads = add_domain_deep($ads, array("pic"));
		}
		return $ads;
	}
}
